<?php

class Ev_View_Helper_TreeView extends Zend_View_Helper_FormSelect
{
    public function treeView($rowSet, $moduleControllerAction, $stCampoChave, $stCampoCodigo, $stCampoDescricao)
    {
        $html = '';
        foreach ($rowSet as $indiceFilho => $row) {
            $html .=
            '
            <li>
                <a href="' . $moduleControllerAction . '/' . $stCampoChave . '/' . $row->$stCampoChave . '">' . $row->$stCampoCodigo . ' - ' . $row->$stCampoDescricao . '</a>
            ';
            if ($row->filhos) {
                    $html .= '
                <ul>
                    ' . $this->treeView($row->filhos, $moduleControllerAction, $stCampoChave, $stCampoCodigo, $stCampoDescricao) . '
                </ul>';
            }
            $html .= '</li>';
        }
        return $html;
    }
}
